package bma.common.langutil.ai.stack;

/**
 * 
 * @author guanzhong
 * @since 1.0 (imported from BMA.ESP Project)
 * 
 * @param <RESP_TYPE>
 */
public abstract class AIStackAbstractDelegate<RESP_TYPE> extends
		AIStackAbstract<RESP_TYPE> {

	private AIStack<RESP_TYPE> delegate;

	public AIStackAbstractDelegate(AIStack<RESP_TYPE> delegate) {
		super();
		this.delegate = delegate;
	}

	@Override
	public AIStack<?> getParent() {
		return delegate;
	}

	public AIStack<RESP_TYPE> delegate() {
		return this.delegate;
	}

	protected boolean done() {
		return false;
	}

	@Override
	public boolean success(RESP_TYPE result) {
		if (done())
			return true;
		return this.delegate.success(result);
	}

	@Override
	public boolean failure(Throwable t) {
		if (done())
			return true;
		return this.delegate.failure(t);
	}

}
